<?php 
/**
 * Site Log file.
 */
if (!class_exists('File')) {
	require LIBS . 'file.php';
}
class SitelogComponent extends Object{
    
    function startup(&$controller){        
		$visited_url=$controller->params['url'];
		if($controller->Session->read('Auth.User.id'))
		$log_data=" ".$controller->Session->read('Auth.User.username')." From IP: ".$_SERVER['REMOTE_ADDR']." URL: ".$visited_url['url'];
		else
		$log_data=" Visitor From IP: ".$_SERVER['REMOTE_ADDR']." URL: ".$visited_url['url'];
		CakeLog::write("SiteLog", $log_data);
    }
	function readSiteLog(){		
		$log = new File(LOGS."SiteLog.log");
		if ($log->readable()) {			
			return $log->read();
		}		
	}
}
?>